/*
 * Copyright 2018- The Pixie Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

syntax = "proto3";

package px.statuspb;

option go_package = "statuspb";

import "google/protobuf/any.proto";

enum Code {
  // Not an error, returned on success.
  OK = 0;
  // The operation was cancelled (typically by the caller).
  CANCELLED = 1;
  // There was an error due to unknown cause. Errors may be converted
  // into this form if APIs don't give enough information to get the correct
  // error codes.
  UNKNOWN = 2;
  // Bad argument was given and a retry will not be successful.
  INVALID_ARGUMENT = 3;
  // The deadline for this operation was exceeded.
  DEADLINE_EXCEEDED = 4;
  // Resource specified was not found.
  NOT_FOUND = 5;
  // The resource already exists and cannot be overridden.
  ALREADY_EXISTS = 6;
  PERMISSION_DENIED = 7;
  UNAUTHENTICATED = 8;
  INTERNAL = 9;
  // Operation specified is not implemented.
  UNIMPLEMENTED = 10;
  // No resources available for action.
  RESOURCE_UNAVAILABLE = 11;
  // Syscall errors.
  SYSTEM = 12;
  // A precondition of the API failed. Might have succeeded otherwise.
  FAILED_PRECONDITION = 13;
  // Use default instead of specifying all entries here. Otherwise, code might get
  // hard to maintain.
  DO_NOT_USE_ = 100;
}

// This is the proto representation of a status.
message Status {
  Code err_code = 1;
  string msg = 2;
  google.protobuf.Any context = 3;
}

// This is a proto representation for common lifecycle states.
enum LifeCycleState {
  // State of the resource is unknown.
  UNKNOWN_STATE = 0;
  // Resource is still in the start up process.
  PENDING_STATE = 1;
  // Resource is active and healthy.
  RUNNING_STATE = 2;
  // Resource is not running and has failed.
  FAILED_STATE = 3;
  // Resource has been terminated with no errors.
  TERMINATED_STATE = 4;
}
